package com.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateHelper
{
	public static boolean isInteger( String number )
	{
		if(number==null)
		{
			return false;
		}
		Pattern pattern = Pattern.compile("^\\d+$"); 
		Matcher m = pattern.matcher( number );
		return m.matches(); 
	}
	
	public static boolean isIpAddress( String ip )
	{
		if( ip==null )
		{
			return false;
		}
		Pattern pattern = Pattern.compile("^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$"); 		 
		Matcher m = pattern.matcher( ip );
		return m.matches(); 
	}
	
	public static boolean isPassword( String pw )
	{
		Pattern pattern = Pattern.compile("^(([a-zA-Z]+[0-9]+[a-zA-Z0-9]*)|([0-9]+[a-zA-Z]+[a-zA-Z0-9]*)$)");
		Matcher m = pattern.matcher( pw );
		return m.matches();
	}
	
	public static void main(String[] args) {
		System.out.println("test:");
		Pattern p = Pattern.compile("([a-z][0-9])+");
		Matcher m = p.matcher("ewwewe");
		System.out.println(m.matches());
	}
}
